{{- if or (not .Values.dashboard.auth.externalAuthentication) (eq (include "helm_lib_module_https_mode" .) "Disabled") }}
  {{- if and (eq (include "helm_lib_module_https_mode" .) "Disabled") (ne .Values.dashboard.accessLevel "User") }}
    {{- cat "On https.mode Disabled the only allowed accessLevel is User" | fail }}
  {{- end }}
---
apiVersion: deckhouse.io/v1
kind: ClusterAuthorizationRule
metadata:
  name: d8-dashboard
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
spec:
  subjects:
  - kind: ServiceAccount
    name: dashboard
    namespace: d8-{{ .Chart.Name }}
  accessLevel: {{ .Values.dashboard.accessLevel }}
  portForwarding: false
  {{- if .Values.dashboard.auth.allowScale }}
  allowScale: true
  {{- end }}
{{- end }}
